<template>
  <div class="dashboard-page">
    <el-page-header content="系统首页" />

    <el-card shadow="hover" class="mt-4">
      <div class="welcome-section">
        <h2>欢迎使用管理系统</h2>
        <p class="text-muted">当前登录时间: {{ currentDateTime }}</p>
      </div>

      <div class="stats-grid mt-6">
        <el-card class="stat-card">
          <div class="stat-content">
            <div class="stat-label">用户总数</div>
            <div class="stat-value">2,458</div>
          </div>
          <el-icon class="stat-icon"><User /></el-icon>
        </el-card>

        <el-card class="stat-card">
          <div class="stat-content">
            <div class="stat-label">角色数量</div>
            <div class="stat-value">36</div>
          </div>
          <el-icon class="stat-icon"><UserFilled /></el-icon>
        </el-card>

        <el-card class="stat-card">
          <div class="stat-content">
            <div class="stat-label">菜单总数</div>
            <div class="stat-value">128</div>
          </div>
          <el-icon class="stat-icon"><Menu /></el-icon>
        </el-card>
      </div>
    </el-card>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { User, UserFilled, Menu } from '@element-plus/icons-vue'

// 当前日期时间
const currentDateTime = ref('')

// 格式化日期时间
const formatDateTime = () => {
  const options = {
    year: 'numeric',
    month: 'long',
    day: 'numeric',
    hour: '2-digit',
    minute: '2-digit',
    second: '2-digit',
    weekday: 'long'
  }
  return new Date().toLocaleDateString('zh-CN', options)
}

// 初始化日期时间并每秒更新
onMounted(() => {
  currentDateTime.value = formatDateTime()
  setInterval(() => {
    currentDateTime.value = formatDateTime()
  }, 1000)
})
</script>

<style scoped>
.dashboard-page {
  padding: 20px;
}

.welcome-section {
  text-align: center;
  padding: 30px 0;
}

.text-muted {
  color: #6c757d;
  margin-top: 10px;
  font-size: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.stat-card {
  display: flex;
  align-items: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.stat-content {
  flex: 1;
}

.stat-label {
  color: #6c757d;
  font-size: 14px;
}

.stat-value {
  font-size: 24px;
  font-weight: bold;
  margin-top: 5px;
  color: #1a1a1a;
}

.stat-icon {
  font-size: 36px;
  color: #409eff;
  opacity: 0.2;
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
}
</style>
